package game.seungha;

import android.util.Log;
import android.widget.Chronometer;
import android.widget.Chronometer.OnChronometerTickListener;

public class Listener_ChronometerTick implements OnChronometerTickListener 
{
	final long ONE_SEC	= 1000;
	final long ONE_MIN	= ONE_SEC*60;
	final long ONE_HOUR	= ONE_MIN*60;
	final long ONE_DAY	= ONE_HOUR*24;

	@Override
	public void onChronometerTick(Chronometer chronometer) 
	{
		long startTime;
		long currentTime;
		long differTime;
		
		long nHour;
		long nMin;
		long nSec;
		long nMSec;
		
		String strPlayTime;
		
		startTime 	= chronometer.getBase();
		currentTime	= System.currentTimeMillis();
		differTime	= currentTime-startTime;
		
		nHour	= (differTime%ONE_DAY)/ONE_HOUR;
		nMin	= (differTime%ONE_HOUR)/ONE_MIN;
		nSec	= (differTime%ONE_MIN)/ONE_SEC;
		nMSec	= differTime%ONE_SEC;
		
		Log.i("DBG", "[Listener_ChronometerTick]onChronometerTick"+" nHour:"+nHour+" nMin:"+nMin+" nSec:"+nSec+" nMSec:"+nMSec);
		
		strPlayTime	= String.format("%02d:%02d:%02d.%02d", nHour, nMin, nSec, nMSec);
		
		chronometer.setText(strPlayTime);
		
		

	}

}
